﻿using OpenAdmin.Application.Redis;

namespace OpenAdmin.Application.CachingServices;

/// <summary>
/// 
/// </summary>
public class ProductCacheService : CachingServiceBase, IProductCacheService, ITransientDependency
{
    /// <summary>
    /// 获取商品分页结果
    /// </summary>
    /// <param name="parameter"></param>
    /// <param name="pageIndex"></param>
    /// <param name="pageSize"></param>
    /// <param name="func"></param>
    /// <returns></returns>
    public async Task<PagedList<ProductListByPageResponseDto>> ProductListByPageAsync(string parameter, int pageIndex, int pageSize, Func<Task<PagedList<ProductListByPageResponseDto>>> func)
        => await Cache.GetOrAddAsync(CachingConsts.CacheKeys.ProductListByPageAsync(parameter, pageIndex, pageSize), func, CachingConsts.CacheStrategy.HALF_DAY);
}
